<template>
  <div class="popular-stocks">
    <div class="card-header">
      <h3>热门股票</h3>
      <el-button type="text">更多</el-button>
    </div>
    <div class="stock-list">
      <div v-for="(stock, index) in stocks" :key="index" class="stock-item">
        <div class="stock-info">
          <span class="stock-name">{{ stock.name }}</span>
          <span class="stock-code">{{ stock.code }}</span>
        </div>
        <div class="stock-price">
          <span class="price">{{ stock.price }}</span>
          <span :class="['change', stock.change >= 0 ? 'up' : 'down']">
            {{ stock.change >= 0 ? '+' : '' }}{{ stock.change }}%
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PopularStocks',
  data() {
    return {
      stocks: [
        { name: '贵州茅台', code: '600519', price: '1,850.00', change: 2.34 },
        { name: '宁德时代', code: '300750', price: '420.50', change: 1.89 },
        { name: '中国平安', code: '601318', price: '45.67', change: -0.56 },
        { name: '招商银行', code: '600036', price: '38.90', change: 0.78 },
        { name: '比亚迪', code: '002594', price: '280.30', change: 3.45 }
      ]
    }
  }
}
</script>

<style scoped>
.popular-stocks {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
  padding: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 18px;
  color: #303133;
  margin: 0;
}

.stock-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stock-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #ebeef5;
}

.stock-info {
  display: flex;
  flex-direction: column;
}

.stock-name {
  font-size: 16px;
  color: #303133;
}

.stock-code {
  font-size: 12px;
  color: #909399;
}

.stock-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.price {
  font-size: 16px;
  font-weight: bold;
  color: #303133;
}

.change.up {
  color: #f56c6c;
}

.change.down {
  color: #67c23a;
}
</style> 